﻿using System;   
using System.Data;   
using System.Configuration;   
using System.Linq;   
using System.Web;   
using System.Web.Security;   
using System.Web.UI;   
using System.Web.UI.HtmlControls;   
using System.Web.UI.WebControls;   
using System.Web.UI.WebControls.WebParts;   
using System.Xml.Linq;   
using System.Text;   

public class UrlReWriter:IHttpModule
{
        #region IHttpModule 成员

        void IHttpModule.Dispose()
        {
        }

        void IHttpModule.Init(HttpApplication context)
        {
            context.BeginRequest += new EventHandler(context_BeginRequest);   
        }

        void context_BeginRequest(object sender, EventArgs e)   
        {   
            HttpApplication application = (HttpApplication)sender;      
            HttpContext context = application.Context;      
            HttpResponse response = context.Response;      
            string path = context.Request.Path;      
            string file = System.IO.Path.GetFileName(path);


            if (file.IndexOf("B2COrderReceiver") >= 0)   
            {
                string[] queryStrings= context.Request.RawUrl.Split("?".ToCharArray());
                string rewritePath = "Admin/B2C/B2COrderReceiver.aspx";
                if(queryStrings.Length>1)
                {
                    rewritePath += "?" + queryStrings[1];
                }
                context.RewritePath(rewritePath);
            }
        }
        #endregion
}
